package com.qidian.buy.cms.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qidian.buy.cms.entity.Content;
import com.qidian.buy.cms.service.IContentService;
import com.qidian.buy.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 戴着假发的程序员
 * @since 2024-05-06
 */
@RestController
@RequestMapping("/content")
public class ContentController {
    @Autowired
    private IContentService contentService;

    @GetMapping("/listByCatMark")
    public QdResult listByCatMark(String catMark,@RequestParam(defaultValue = "0") int count){
        return contentService.listByCarMark(catMark,count);
    }
    @GetMapping("/listPage")
    public QdResult<IPage<Content>> listPage(Content content,@RequestParam(defaultValue = "1")int page,@RequestParam(defaultValue = "10")int limit){
        return contentService.queryByPage(content,page,limit);
    }
    @PostMapping("/save")
    public QdResult save(@RequestBody Content content){
        return contentService.save(content);
    }
    @GetMapping("/list")
    public QdResult list(Content content, @RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10")int limit){
        return contentService.listByPageAndContent(page,limit,content);
    }
}
